
{{ include("common/header.html")}}
<div class="admin">
    {{ include("common/nav.html")}}
    <link rel="stylesheet" href="{{_G['APP']}}/resource/wangEditor/css/wangEditor.min.css">
    <script type="text/javascript" src="{{_G['APP']}}/resource/js/jquery.min.js"></script>
    <script type="text/javascript" src="{{_G['APP']}}/resource/wangEditor/js/wangEditor.min.js"></script>
    <div class="aright">
        <style type="text/css">
            .tpt_sels a{padding-right:15px;position:relative}
            .tpt_sels a{padding:0 20px 0 8px;color:#3B6268;background:#FFFFBA;border:1px #F8E06E solid;margin-right:5px;margin-bottom:5px;font-size:14px;height:26px;line-height:26px;display:block;float:left}
            .tpt_pres a.selected{padding:0 8px;color:#3B6268;background:#FFFFBA;border:1px #F8E06E solid;margin-right:5px;margin-bottom:5px;font-size:14px;height:26px;line-height:26px;display:block;float:left}
            .tpt_pres a{padding:0 8px;color:#fff;background:#5AC7A9;border:1px #5AC7A9 solid;margin-right:5px;margin-bottom:5px;font-size:14px;height:26px;line-height:26px;display:block;float:left}
            .tpt_sels a em{width: 12px;height: 12px;font-style: normal;display: block;position: absolute;top: 7px;right: 4px;z-index: 2;background: url(/blog/Public/img/sx.png) no-repeat 0 0;}
            .wangEditor-menu-container .menu-item a {padding: 12px 0;}
            .wangEditor-menu-container .menu-item {height: 37px;width: 37px;}
            .wangEditor-menu-container .menu-group {padding: 0;}
            .wangEditor-container {border: 1px solid #e6e6e6;}
        </style>
        <fieldset class="layui-elem-field layui-field-title" style="margin: 20px 30px 20px 20px;">
            <legend>添加分类</legend>
        </fieldset>

        <form class="layui-form bform" method="post" action="{{ G.url('admin/classify/add')}}" enctype="multipart/form-data">

            <div class="layui-form-item">
                <label class="layui-form-label">栏目名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" required="" lay-verify="required" placeholder="必填内容" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item" style="width: 300px;">
                <label class="layui-form-label">所属栏目</label>
                <div class="layui-input-block">
                    <select name="pid">
                        <option value="0">顶级栏目</option>
                        <!--{% for vo in list %}-->
                        <!--<option value={{vo.id}}>{{vo.name}}</option>-->
                        <!--{% endfor %}-->
                    </select>
                </div>
            </div>

            <input type="hidden" name="submit" value="1"/>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
                    <div class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</div>
                </div>
            </div>
        </form>
        <script type="text/javascript">
            $(function() {
                $('#tpt_input').keydown(function(e) {
                    if (e.which === 13) {
                        $("#tpt_btn").click();
                        e.preventDefault();
                        return false;
                    }
                });
                $("#tpt_sel").on('click', 'a>em', function() {
                    var name = "keywords";
                    var tag = $(this).parent().text();
                    $(this).parent().remove();
                    var tags = new Array();
                    $("#tpt_sel").find('a').each(function() {
                        tags.push($(this).text());
                    });
                    $("input[name=" + name + "]").val(tags.join(","));
                    $("#tpt_pre a:contains('" + tag + "')").removeClass("selected");
                });
                $("#tpt_btn").click(function() {
                    var name = "keywords";
                    var tags = $.trim($("input[name=" + name + "]").val());
                    if (tags !== "") {
                        tags = tags.split(",");
                    } else {
                        tags = new Array();
                    }
                    var tag = $.trim($("#tpt_input").val());
                    if (tag !== '' && $.inArray(tag, tags) === -1) {
                        tags.push(tag);
                        $("#tpt_pre a:contains('" + tag + "')").addClass("selected");
                    }
                    $("#tpt_sel").children('span').empty();
                    $.each(tags, function(k, v) {
                        $("#tpt_sel").children('span').append('<a href="javascript:;">' + v + '<em></em></a>');
                    });
                    $("input[name=" + name + "]").val(tags.join(","));
                    $("#tpt_input").val('');
                });
                $("#tpt_pre").on('click', 'a:not(.selected)', function() {
                    var name = "keywords";
                    var tags = $.trim($("input[name=" + name + "]").val());
                    if (tags !== "") {
                        tags = tags.split(",");
                    } else {
                        tags = new Array();
                    }
                    var tag = $.trim($(this).text());
                    if (tag !== '' && $.inArray(tag, tags) === -1) {
                        tags.push(tag);
                    }
                    $("#tpt_sel").children('span').empty();
                    $.each(tags, function(k, v) {
                        $("#tpt_sel").children('span').append('<a href="javascript:;">' + v + '<em></em></a>');
                    });
                    $("input[name=" + name + "]").val(tags.join(","));
                    $(this).addClass('selected');
                });
            });
        </script>
        <script>
            layui.use('form', function(){
                var form = layui.form();
            });
        </script>

    </div>
</div>
</body>
</html>